#include "TcpServer.hpp"
#include "Protocol.hpp"
#include "ServerCal.hpp"
#include <functional>
#include<iostream>

void Warn(char *in)
{
    std::cout<<"User port"<<*in<<" [1024+]"<<std::endl;
}

int main(int argc,char *argv[])
{
    if(argc!=2)
    {
        Warn(argv[0]);
        exit(0);
    }

    uint16_t port = std::stoi(argv[1]);
    Servercal cal;
    //Tcpserver *_local = new Tcpserver(port, std::bind(&Servercal::Calculator, &cal, std::placeholders::_1));

    Tcpserver _local(port,std::bind(&Servercal::Calculator,&cal,std::placeholders::_1));
    _local.Init();
    _local.Start();

    /*Request re(123,321,'+');
    std::string out;
    re.Serialization(&out);//序列化

    std::cout<<out<<std::endl;

    //re.Deserialization(out);//反序列化
    //std::cout<<re.x<<" "<<re.op<<' '<<re.y<<std::endl;
    std::string temp = Encode(out);
    std::cout<<temp;

    std::string ret = Decode(&temp);
    std::cout<<ret<<std::endl;*/

    // Response re(100,0);
    // std::string out;

    // re.Serialization(&out);
    // std::cout<<out<<std::endl;

    // re.Deserialization(out);
    // std::cout<<re.result<<' '<<re.Flags<<std::endl;
    // std::string temp = Encode(out);
    // std::cout<<temp;
    // std::string ret = Decode(&temp);
    // std::cout<<ret<<std::endl;
    return 0;
}